home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 2 (DVD) / XENIADVD2.iso / Patch / Project Nomads / pnomads_patch2_eng.exe / MAINDIR / Run / scripts / menuaction.tcl < prev    next >
Encoding:
Text File  |  2002-09-29  |  6.8 KB  |  214 lines

  1. #-------------------------------------------------------------------------------
  2. #   menuaction.tcl
  3. #
  4. #   All function for the Nomads menu.
  5. #-------------------------------------------------------------------------------
  6.  
  7. # single player clan color constants
  8. set sp_clancolor_john_red      0.0
  9. set sp_clancolor_john_green    0.7
  10. set sp_clancolor_john_blue     0.9
  11.  
  12. set sp_clancolor_goliath_red   1.0
  13. set sp_clancolor_goliath_green 0.1
  14. set sp_clancolor_goliath_blue  0.0
  15.  
  16. set sp_clancolor_susie_red     0.7
  17. set sp_clancolor_susie_green   0.9
  18. set sp_clancolor_susie_blue    0.0
  19.  
  20. #-------------------------------------------------------------------------------
  21.  
  22.  
  23. # multiplayer clancolor variables
  24. set mp_clancolor_red   1.0
  25. set mp_clancolor_green 1.0
  26. set mp_clancolor_blue  1.0
  27.  
  28. # the selected character prototype
  29. set character_proto    char_john
  30.  
  31. #-------------------------------------------------------------------------------
  32. #   m_startgamefrombook
  33. #
  34. #   Wraps starting a new game and loads the book given as argument.
  35. #-------------------------------------------------------------------------------
  36. proc m_startgamefrombook {book} {
  37. global home
  38.  
  39. global sp_clancolor_john_red
  40. global sp_clancolor_john_green
  41. global sp_clancolor_john_blue
  42. global sp_clancolor_goliath_red
  43. global sp_clancolor_goliath_green
  44. global sp_clancolor_goliath_blue
  45. global sp_clancolor_susie_red
  46. global sp_clancolor_susie_green
  47. global sp_clancolor_susie_blue
  48.  
  49. global character_proto
  50.  
  51.     # pause the game
  52.     /world.pausegame
  53.  
  54.     # execute the right alias routine based on character_proto variable
  55.     set backpack ""
  56.     if {$character_proto == "char_john"} {
  57.         john_aliases
  58.         set backpack "backpack"
  59.         set sp_clancolor_red   $sp_clancolor_john_red 
  60.         set sp_clancolor_green $sp_clancolor_john_green 
  61.         set sp_clancolor_blue  $sp_clancolor_john_blue
  62.     } elseif {$character_proto == "char_goliath"} {
  63.         goliath_aliases
  64.         set backpack "backpack_g"
  65.         set sp_clancolor_red   $sp_clancolor_goliath_red 
  66.         set sp_clancolor_green $sp_clancolor_goliath_green 
  67.         set sp_clancolor_blue  $sp_clancolor_goliath_blue
  68.     } elseif {$character_proto == "char_susie"} {
  69.         susie_aliases
  70.         set backpack "backpack_s"
  71.         set sp_clancolor_red   $sp_clancolor_susie_red 
  72.         set sp_clancolor_green $sp_clancolor_susie_green 
  73.         set sp_clancolor_blue  $sp_clancolor_susie_blue
  74.     }
  75.  
  76.     # load the book
  77.     /world.loadbook2 $book
  78.  
  79.     /world.settimeofday         50000
  80.     /sys/servers/channel.setchannel1f windstrength 0.1
  81.     /sys/servers/channel.setchannel1f winddir      33
  82.  
  83.     # connect camera to JOHN (speziell fⁿr XBOX DEMO)
  84.     /world.setviewercarrier [[/world.getuserclan].getmaennel]
  85.     /world.sethandcontrol   [[/world.getuserclan].getmaennel]
  86.     
  87.     # Activate fast possess by default
  88.     /world.activatefastpossess
  89.  
  90.     # set the clan color
  91.     [/world.getuserclan].setclancolor $sp_clancolor_red $sp_clancolor_green $sp_clancolor_blue
  92.  
  93.     # ATTACH BACKPACK
  94.     [[/world.getuserclan].getmaennel].setattachslottarget 0 $backpack
  95.  
  96.     if {[exists /world/gui/splashscreen]} { delete /world/gui/splashscreen }
  97.  
  98.     # continue game and fadein
  99.     /world.contgame
  100.     /game/handler/cookie.setcookie "_character" $character_proto
  101.     puts "charname:"
  102.     puts [friendname]
  103.     puts "<-- m_startgamefrombook"
  104. }
  105.  
  106. #-------------------------------------------------------------------------------
  107. #   m_newgame
  108. #   Start a new single player game.
  109. #-------------------------------------------------------------------------------
  110. proc m_newgame {} {
  111.     m_startgamefrombook "home:book"
  112. }
  113.  
  114. #-------------------------------------------------------------------------------
  115. # Play test level
  116. #-------------------------------------------------------------------------------
  117. proc m_testbook {} {
  118.     m_startgamefrombook "home:data/book"
  119. }
  120.  
  121. #------------------------------------------------------------------------------
  122. #   m_createcharacter
  123. #   Create a character for the various session types. A client creates a clan
  124. #   with the character, a host searches the userclan for a character and
  125. #   replaces it with a new character. The character proto is defined
  126. #   by the global variable 
  127. #------------------------------------------------------------------------------
  128. proc m_createcharacter {} {
  129. global mp_clancolor_red
  130. global mp_clancolor_green
  131. global mp_clancolor_blue
  132. global character_proto
  133. global home
  134.  
  135.     # single player case: search "maennel" and
  136.     # replace it with the selected character
  137.     if {[/world.isnetsession] == "false"} {
  138.  
  139.         # get user clan and its maennel
  140.         set clan [/world.getuserclan]
  141.         if {$clan == "null"} {
  142.             puts "*** no user clan on character creation"
  143.             return
  144.         }
  145.         set maennel [$clan.getmaennel]
  146.         if {$maennel == "null"} {
  147.             puts "*** no maennel in user clan on character creation"
  148.             return
  149.         }
  150.         
  151.         # create new maennel
  152.         set new_maennel [$clan.createvehicle $character_proto]
  153.  
  154.         
  155.         # align position and orientation and state with original
  156.         $new_maennel.alignvehicle $maennel 0 0 0 0 0 0
  157.         $new_maennel.setstate [$maennel.getstate]
  158.         $new_maennel.setmaxartefacts [$maennel.getmaxartefacts]
  159.  
  160.         # release original
  161.         $clan.releasevehicle $maennel
  162.  
  163.         return
  164.     }
  165.     
  166.     # multiplayer case: server or client?
  167.     if {[/world.ishost] == "true"} {
  168.  
  169.         # Load character and island from slot
  170.         set clan [/world.getuserclan]
  171.         if {$clan != "null"} {
  172.             puts $clan
  173.         }
  174.         set filename $home/save/characters/$character_proto
  175.         /world.loadcharacter $filename
  176.  
  177.         # get user clan and its maennel
  178.         set clan [/world.getuserclan]
  179.         if {$clan == "null"} {
  180.             puts "*** no user clan on character creation"
  181.             return
  182.         }
  183.  
  184.         set maennel [$clan.getmaennel]
  185.         if {$maennel == "null"} {
  186.             puts "*** no maennel in user clan on character creation"
  187.             return
  188.         }
  189.  
  190.         /world.sethandcontrol $maennel
  191.         /world.setviewercarrier $maennel
  192.  
  193.     } else {
  194.  
  195.         # Load character from slot
  196.         set filename $home/save/characters/$character_proto
  197.         /world.loadcharacter $filename
  198.  
  199.         set clan [/world.getuserclan]
  200.         set maennel [$clan.getmaennel]
  201.         /world.sethandcontrol $maennel
  202.         /world.setviewercarrier $maennel
  203.     }
  204.     
  205.     # multiplayer: let every clienbt start with different faction to
  206.     # guarantee enemy state. possible with machine id
  207.     set clan [/world.getuserclan]
  208.     $clan.setfaction [/sys/servers/comm.getclientid]
  209.  
  210.     # set the clan color
  211.     [/world.getuserclan].setclancolor $mp_clancolor_red $mp_clancolor_green $mp_clancolor_blue
  212. }
  213.  
  214.